<?xml version="1.0" encoding="utf-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

	<div id='cadastraritem-form'>
		<div class='inside'>

			<h1>Buscar Item</h1>			

			<!-- Progress -->
			<p:ajaxStatus onstart="PF('statusDialog').show();" onsuccess="PF('statusDialog').hide();"/>  

			<p:dialog modal="true" widgetVar="statusDialog" header="Aguarde"   
					draggable="false" closable="false">  
				<p:graphicImage value="resources/imagens/progress.gif" />  
			</p:dialog>
			
			<!-- Formulário -->
			<h:form>
				<h:messages id="messagesBuscarItem" globalOnly="true" />
				<h:panelGrid columns="1">
					
					<!-- Nome do Item -->
					<h:outputLabel value="Item" for="descricao" />
					<h:inputText class="defaultBoxRadius" id="descricao"
						value="#{listarItensBean.descricao}" size="45"
						required="true">
						<f:validateLength maximum="45" />
						<p:ajax event="keyup" update="tb_itens" listener="#{listarItensBean.listarItens}"></p:ajax>
					</h:inputText>
					<h:message for="descricao" />					
				</h:panelGrid>
			    
			    <!-- Listagem dos itens -->
			    <p:dataTable id="tb_itens"
					value="#{listarItensBean.itens}"
					var="item" 
					>
					
					<p:column headerText="Descrição">
						<p:graphicImage value="resources/imagens/nophoto.png"/>
					</p:column>					
					
					<p:column headerText="Categoria">
						<h:outputText value="#{item.categoria.descricao}" />
					</p:column>
					
					<p:column headerText="Descrição">
						<h:outputText value="#{item.descricao}" />
					</p:column>
					
					<p:column headerText="Região">
						<h:outputText value="#{item.regiao.nome}" />
					</p:column>				
					
					<p:column headerText="Opções">						
							<p:commandLink id="reservarItemLink" 
								actionListener="#{listarItensBean.reservarItem(item)}" 
								ajax="false">
								<h:outputText value="Reservar" />
							</p:commandLink>					
					</p:column>
					
				</p:dataTable>	
			</h:form>
		</div>
	</div>
</ui:composition>